* Do file: Institutional Constraints, Legislative Activism, and Policy Change: The Case of the European Union

xtset panel year, yearly

* Summary stats: Appendix I
xtsum Change_in_regulatory_density proposals gridlock elec1 elec2 elec3 elec4 elec5 EU_membership policydocs

* Counting number of proposals
gen runsum = sum(proposals)
sum runsum
* Counting number of regulatory changes
gen runsum2 = sum(Change_in_regulatory_density)
sum runsum2

* generating binary regulation variable: 1=change in regulation; 0 = no change	
recode Change_in_regulatory_density (0=0) (0/max=1), gen(regulation1)

xtline proposals, byopts(title(Figure 1. Legislative proposals over time: Eight sectors, size(medlarge) ring(1)))

xtline gridlock, byopts(title(Figure 1. Legislative proposals over time: Eight sectors, size(medlarge) ring(1)))

xtline Change_in_regulatory_density, byopts(title(Figure 1. Legislative proposals over time: Eight sectors, size(medlarge) ring(1)))

xtline Change_in_regulatory_density

xtsum proposals Change_in_regulatory_density

* Table 1: Explaining Policy Entrepreneurship
* #1
xtnbreg proposals l.gridlock, fe irr 
outreg2 using table1.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append

* #2
xtnbreg proposals l.gridlock trend, fe irr 
outreg2 using table1.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append

* #3
xi: xtnbreg proposals l.gridlock i.election trend, fe irr 
outreg2 using table1.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append
testparm _Ielection_2 - _Ielection_5

* #4
xi: xtnbreg proposals l.gridlock i.election l.EU_membership trend, fe irr 
outreg2 using table1.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append
testparm _Ielection_2 - _Ielection_5



		**** Preamble to Table 2
		* Figure 1: Lag structure (eclplot)
		* Akaike Information Criterion

		xtnbreg Change_in_regulatory_density proposals, fe irr 
		estimates store lag0
		testparm proposals
		
		xtnbreg Change_in_regulatory_density l.proposals, fe irr
		estimates store lag1
		testparm l.proposals
		
		xtnbreg Change_in_regulatory_density l2.proposals, fe irr
		estimates store lag2
		testparm l2.proposals
		
		xtnbreg Change_in_regulatory_density l3.proposals, fe irr
		estimates store lag3
		testparm l3.proposals
		
		coefplot lag0 lag1 lag2 lag3, drop(_cons) yline(0) vertical nolabels title(Figure 2. Time lags) subtitle(Legislative proposals and regulatory change) ytitle(Coefficients and 95% CI) xtitle(Lags of legislative proposals) coeflabel(proposals = "Lag t=0" l.proposals = "Lag t-1" l2.proposals = "Lag t-2" l3.proposals = "Lag t-3") 
		drop _est_lag0- _est_lag3


		
* Table 2: Explaining regulatory activity
* #1
xtnbreg Change_in_regulatory_density l2.proposals, fe irr 
outreg2 using table2.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append

* #2
xtnbreg Change_in_regulatory_density l2.proposals trend, fe irr 
outreg2 using table2.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append

* #3
xi: xtnbreg Change_in_regulatory_density l2.proposals l.gridlock trend, fe irr 
outreg2 using table2.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append

* #4
xi: xtnbreg Change_in_regulatory_density l2.proposals l.gridlock i.election trend, fe irr 
outreg2 using table2.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append
testparm _Ielection_2 - _Ielection_5

* #5
xi: xtnbreg Change_in_regulatory_density l2.proposals l.gridlock i.election l.EU_membership trend , fe irr 
outreg2 using table2.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append
testparm _Ielection_2 - _Ielection_5

* #6 Interactions: Interaction of formal (proposals) and informal (policy docs) agenda-setting + control
xi: xtnbreg Change_in_regulatory_density l2.c.proposals##l2.c.policydocs l.gridlock i.election l.EU_membership trend, fe irr 
outreg2 using table2.doc, stnum(replace coef=exp(coef), replace se=coef*se) cti(irr) stats(coef tstat) bdec(2) tdec(2) append
testparm _Ielection_2 - _Ielection_5


* Figure

gen election = year
label var election "EP election cycle"
recode election (1984=1) (1985=2) (1986=3) (1987=4) (1988=5) (1989=1) (1990=2) (1991=3) (1992=4) (1993=5) (1994=1) (1995=2) (1996=3) (1997=4) (1998=5) (1999=1) (2000=2) (2001=3) (2002=4) (2003=5) (2004=1) (2005=2) (2006=3) (2007=4) (2008=5) (2009=1) (2010=2) (2011=3) (2012=4)


* Figure 1: Density plot: All sectors collapsed (total time series)
hist Change_in_regulatory_density

kdensity Change_in_regulatory_density, title(Figure 1. Density of Regulatory Changes) subtitle(Eight Sectors: 1984-2012) note(Note: X-axis is the count of regulatory changes)
sum Change_in_regulatory_density, detail

kdensity proposals, title(Figure 2. Density of Legislative Proposals) subtitle(Eight Sectors: 1984-2012) note(Note: X-axis is the count of legislative proposals)
sum Change_in_regulatory_density, detail


xtline proposals
xtline policydocs
xtline Change_in_regulatory_density


* Figure 2
xtline proposals



***** Notes

*** Granger causality tests
xtnbreg proposals l.Change_in_regulatory_density, fe irr
xtnbreg proposals l2.Change_in_regulatory_density, fe irr
xtnbreg proposals l3.Change_in_regulatory_density, fe irr


* Proposals as DV
xtnbreg proposals l.gridlock trend, fe irr 
